<style>
.xiadan_box2 .shan{ float:left;  margin-top:40px;}
.xiadan_box2 .shan input{-webkit-appearance:none; border: 0}
.xiadan_box2 .shan input[type="checkbox"] { background: url(/statics/images/gou-wxz.png) no-repeat center;background-size: 16px; height: 16px;  vertical-align: middle;  width: 16px;}
.xiadan_box2 .shan input[type="checkbox"]:checked { background: url(/statics/images/gou-xz.png) no-repeat center;background-size: 16px; height: 16px;  vertical-align: middle;  width: 16px;}
.xiadan_sl {}
.dpmc{padding: 10px 10px 2px 10px; font-size: 12px; color: #666; margin-top:10px;background: #fff url(/statics/images/dian.png) no-repeat 10% bottom ; background-size: 20px; border-top:1px solid #eee}
.dpmc input{float:left; margin:0 40px 0 0;-webkit-appearance:none; border: 0 }
.dpmc input[type="checkbox"] { background: url(/statics/images/gou-wxz.png) no-repeat center;background-size: 16px; height: 16px;  vertical-align: middle;  width: 16px;}
.dpmc  input[type="checkbox"]:checked { background: url(/statics/images/gou-xz.png) no-repeat center;background-size: 16px; height: 16px;  vertical-align: middle;  width: 16px;}
.xiadan_box3 .shan2{ background:#999; float:left; line-height:0; padding:7px 10px; line-height:16px; margin-top:10px}
</style>
<script src="/statics/js/layer.js"></script>
<!-- 头部开始 -->
<div class="header" style="position: fixed;top:0;z-index: 9;">
	<div class="header_r"><span class="scsc" id="del">删除</span></div>
    <div class="header_m">购物车</div>
</div>
<!-- 头部结束 -->
<div style="height:44px;"></div>
<!--确认下单bx2开始-->
<?php if($data){foreach($data AS $k=>$val){?>
<div class="this-che">
<p class="dpmc"><input type="checkbox" value="100" /><a href="/index/index/sek/<?=mySpreadSek($k)?>"><?=$val['msg']['cust_realname']?>店铺</a></p>
<div class="xiadan_box2">
	<?php if($val['goods']){$goodsNum = 0;foreach($val['goods'] AS $key=>$vals){$newPrice = M('GoodsEntity')->getFieldByGoodsId($vals['goods_id'],'goods_price');?>
	<div class="areaClass">
	    <dl style="position: relative;">
	    	<div class="shan"><label style="float: left; padding:5px 5px 5px 0"><input type="checkbox" class="ichose" value="<?=$vals['id']?>" /></label></div>
            <div class="gou-ding">
			<span>
	    	<?php if($newPrice == $vals['goods_price']){?>
	    	<em>¥ <?=$vals['goods_price']?></em>
	    	<?php }else{?>
	    	<i>¥<?=$vals['goods_price']?></i><br /><em>¥ <?=$newPrice?></em>
	    	<?php }?>
	        <br />
				<i>税费：￥<?=$vals['goods_taxes_price']?></i><br />
				<a href="/cart/remove/id/<?=$vals['goods_id']?>" class="removeIt" style="position: absolute;right: 0;bottom: 0;">
					<img src="/statics/images/lajitong.png" width="15">
				</a>
			</span>
	        <dt><a href="/goods/detail/id/<?=$vals['goods_id']?>/sek/<?=mySpreadSek($vals['biz_cust_id'])?>"><img src="<?=transUrl($vals['goods_pic'])?>" width="70"></a></dt>
	        <dd><a href="/goods/detail/id/<?=$vals['goods_id']?>/sek/<?=mySpreadSek($vals['biz_cust_id'])?>"><?=$vals['goods_title']?></a></dd>
	        <?php $getKcun = M('GoodsEntity')->getFieldByGoodsId($vals['goods_id'],'kcun');?>
            <dd class="xiadan_xh"><!--规格：<?=$vals['goods_attr']?>&nbsp;&nbsp;--><em>库存：<i><?=$getKcun?></i> <?=$vals['goods_attr']?></em></dd>
            <dd class="xiadan_sl">
            <span>
	            <input type="hidden" value="<?=$vals['goods_id']?>" class="gid" />
	            <input type="hidden" value="<?=$vals['biz_cust_id']?>" class="bid" />
	            <input class="canshu_add jianbtn" itv="<?=$k.$key?>" type="button" value=""  />
	            <input type="text" id="num" value="<?=$vals['goods_num']?>" class="num num<?=$k.$key?>" value="1" />
	            <input class="canshu_add addbtn" itv="<?=$k.$key?>" type="button" value="" />
	        </span>
            </dd>
            </div>
	    </dl>
	    
    </div>
   <?php $goodsNum += $vals['goods_num'];}}?> 
    <!--<p style="display:inline">共计<div style="display:inline" class="divNum"><?=$goodsNum?></div>件商品</p>-->
</div>
</div>
<?php }}else{?>
	<div style="width:100%;text-align:center;margin-top:50%">购物车空空~</div>
<?php }?>
<!--确认下单bx2结束-->
<div style="height:60px;"></div>
<?php if($data){?>
<!--确认下单box3开始-->
<!--<div class="xiadan_box3">-->
    <!--实际应付：<em id="sumPrice"></em> 元<a href="javascrpt:void(0)" id="putsubmit">提交订单</a>-->
	<!--<span><label><input type="checkbox" id="btn1"/>全选</label></span>-->
<!--</div>-->
<div class="xiadan_box3">
	<a href="javascrpt:void(0)" style="float:right; line-height: 24px; padding:4px 10px; margin-top:10px" id="putsubmit">提交订单</a>
<span style="float:left"><label><input type="checkbox" id="btn1"/>全选</label></span>
<p class="shuif">实际应付：<em id="sumPrice"></em><br/><i>含运费：<small id="express">0.00</small>　税费：<small id="taxes">0.00</small></i></p >
</div>
<!--确认下单box3结束-->
<?php }else{?>
	<div class="fiex nav"> 
	<?php if($sek){?>
	<a class="icon-shouye" href="/index/index/sek/<?=$sek?>"><br />
	  首页</a> <a class="icon-fenlei" href="/cate/main/sek/<?=$sek?>"><br />
	  分类</a>
	   <a class="icon-gouwu fiex_on" href="/cart/index/sek/<?=$sek?>"><br />
	  购物车</a> <a class="icon-geren" href="/index/user/sek/<?=$sek?>"><br />
	  用户中心</a> </div>
	<?php }else{?>
	   <a class="icon-gouwu fiex_on" style="width:50%" href="/cart/index"><br />
	  购物车</a> <a style="width:50%" class="icon-geren" href="/index/user"><br />
	  用户中心</a> </div>
	  <?php }?>
<?php }?>

<div class="che-true3 che-true2">
	<p>已加入购物车</p>
</div>

<script type="text/javascript">//点击增加、减少产品数量
$(function(){
	/*全选*/
	$("#btn1").click(function(){
		var oDiv = $("#btn1").prop("checked");
		if(oDiv==true){
			$(".this-che input").attr("checked", true);
			$('#del').css('display','block');
		}
		else{
			$(".this-che input").attr("checked", false);
			$('#del').css('display','none');
		}
		docount();
	});
	setInterval(function(){
		var val = $('#num').val();
		if(isNaN(val) || !val){ 
			$('#num').val('');
            
			return false;
		}
	},200);
   
	$('.ichose').click(function(){
		var oDiv2 = $(this).prop('checked');
		if(oDiv2==true){
			$('#del').css('display','block');
		}
		else{
			var i = 0;
			$('.ichose:checked').each(function(){
				i++;
			});
			if(i==0){
				$('#del').css('display','none');
				$('#btn1').prop('checked',false);
			}
		}
	});

	$('#del').click(function(){
		var Id ='';
		$('.ichose:checked').each(function(){
			Id = Id + $(this).val() + '_';
		});
		$.get('/cart/cartdel',{'id':Id},function(data){
			if(data.code == '1'){
				$('.che-true3 p').html(data.msg);
				$('.che-true3').css('display','block');
				setTimeout(time,2500);
				function time(){
					$('.che-true3').css('display','none');
					window.location.reload();
				}
			}else{
				alert(data.msg);
			}
		},'json');
	});


	$('.removeIt').click(function(){
		_this = $(this);
		layer.confirm('确认删除该商品吗 ?', { btn: ['确认','取消']},       
	               function(){
					 	$.get(_this.attr('href'),{},function(data){
					 		layer.msg(data.msg, {icon: data.code });
					 		setTimeout(function(){location.reload()},1000);
					 	},'json');
	   			   },    
	               function(){
	   					//
	   			   });
		return false;
	});
	$('.addbtn').click(function(){
		$(this).prev('.num').val(parseInt($(this).prev('.num').val())+1);
		var vhtml = $(this).parents('.xiadan_box2').find('.divNum');
		vhtml.html(parseInt(vhtml.html())+1);
		if($(this).parents('.areaClass').find('.ichose').attr('checked') == 'checked'){
			docount();
		}
	});
	$('.jianbtn').click(function(){
		if($(this).next('.num').val() > 1){
			$(this).next('.num').val(parseInt($(this).next('.num').val())-1);
			var vhtml = $(this).parents('.xiadan_box2').find('.divNum');
			vhtml.html(parseInt(vhtml.html())-1);
			if($(this).parents('.areaClass').find('.ichose').attr('checked') == 'checked'){
				docount();
			}
		}
	});
	$('#putsubmit').click(function(){
		comb = [];
		$('.ichose:checked').each(function(){
			var mps = $(this).parents('.areaClass');
			comb.push(mps.find('.gid').val()+'_'+mps.find('.num').val()+'_'+mps.find('.bid').val());
		});
		if(comb.length > 0){
			$.get('/cart/putOrder',{'params':comb.join(',')},function(data){
				if(data.code == '1'){
					window.location = '/order/submit/params/'+data.data+'/sek/<?=I('get.sek')?>';return false;
				}else{
					layer.msg(data.msg, {icon: 0});
				}
			},'json');
		}else{
			layer.msg('需要先选择商品哦~', {icon: 0});
		}
	});
	$('.ichose').click(function(){
		docount();
	});
	function docount(){
		pval = [];
		$('.ichose:checked').each(function(){
			var mps = $(this).parents('.areaClass');
			pval.push(mps.find('.gid').val()+'_'+mps.find('.num').val());
		});
		if(pval.length > 0){
			$.get('/cart/count',{'params':pval.join(',')},function(data){
				if(data.code == '1'){
					if(data.data['priceNum'] < 99){
						$('#express').html('10.00');
						$('#sumPrice').html((data.data['priceNum']+data.data['taxesPrice']+10).toFixed(2));
					}else{
						$('#sumPrice').html((data.data['priceNum']+data.data['taxesPrice']).toFixed(2));
					}
					$('#taxes').html(data.data['taxesPrice']);
				}
			},'json');
		}else{
			$('#sumPrice').html('0.00');
		}
	}
	docount();
})
</script>
<script>
    $(document).ready(function(){
       $('.dpmc').click(function(){
            var oDiv3 = $(this).find('input').prop('checked');
            if(oDiv3==true){
                $(this).parents('.this-che').find('input').attr("checked", true);
                $('.scsc').css('display','block');
            }
            else{
                $(".this-che input").attr("checked", false);
                $('.scsc').css('display','block');
            }
        })           
    })
</script>